package invaliddotnetbusinessservicedependency;

import java.util.Arrays;
import org.eclipse.viatra2.emf.incquery.runtime.api.IPatternMatch;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BasePatternMatch;
import org.eclipse.viatra2.patternlanguage.core.patternLanguage.Pattern;
import sysmodel.BusinessService;
import sysmodel.dotNetBusinessService;

/**
 * Pattern-specific match representation of the InvalidDotNetBusinessServiceDependency pattern, 
 * to be used in conjunction with InvalidDotNetBusinessServiceDependencyMatcher.
 * 
 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
 * Each instance is a (possibly partial) substitution of pattern parameters, 
 * usable to represent a match of the pattern in the result of a query, 
 * or to specify the bound (fixed) input parameters when issuing a query.
 * 
 * @see InvalidDotNetBusinessServiceDependencyMatcher
 * @see InvalidDotNetBusinessServiceDependencyProcessor
 * 
 */
public final class InvalidDotNetBusinessServiceDependencyMatch extends BasePatternMatch implements IPatternMatch {
  private dotNetBusinessService fDotNetService;
  
  private BusinessService fOtherService;
  
  private static String[] parameterNames = {"dotNetService", "otherService"};
  
  public InvalidDotNetBusinessServiceDependencyMatch(final dotNetBusinessService pDotNetService, final BusinessService pOtherService) {
    this.fDotNetService = pDotNetService;
    this.fOtherService = pOtherService;
    
  }
  
  @Override
  public Object get(final String parameterName) {
    if ("dotNetService".equals(parameterName)) return this.fDotNetService;
    if ("otherService".equals(parameterName)) return this.fOtherService;
    return null;
    
  }
  
  public dotNetBusinessService getDotNetService() {
    return this.fDotNetService;
    
  }
  
  public BusinessService getOtherService() {
    return this.fOtherService;
    
  }
  
  @Override
  public boolean set(final String parameterName, final Object newValue) {
    if ("dotNetService".equals(parameterName) && newValue instanceof sysmodel.dotNetBusinessService) {
    	this.fDotNetService = (sysmodel.dotNetBusinessService) newValue;
    	return true;
    }
    if ("otherService".equals(parameterName) && newValue instanceof sysmodel.BusinessService) {
    	this.fOtherService = (sysmodel.BusinessService) newValue;
    	return true;
    }
    return false;
    
  }
  
  public void setDotNetService(final dotNetBusinessService pDotNetService) {
    this.fDotNetService = pDotNetService;
    
  }
  
  public void setOtherService(final BusinessService pOtherService) {
    this.fOtherService = pOtherService;
    
  }
  
  @Override
  public String patternName() {
    return "InvalidDotNetBusinessServiceDependency";
    
  }
  
  @Override
  public String[] parameterNames() {
    return InvalidDotNetBusinessServiceDependencyMatch.parameterNames;
    
  }
  
  @Override
  public Object[] toArray() {
    return new Object[]{fDotNetService, fOtherService};
    
  }
  
  @Override
  public String prettyPrint() {
    StringBuilder result = new StringBuilder();
    result.append("\"dotNetService\"=" + prettyPrintValue(fDotNetService) + ", ");
    
    result.append("\"otherService\"=" + prettyPrintValue(fOtherService)
    );return result.toString();
    
  }
  
  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((fDotNetService == null) ? 0 : fDotNetService.hashCode()); 
    result = prime * result + ((fOtherService == null) ? 0 : fOtherService.hashCode()); 
    return result; 
    
  }
  
  @Override
  public boolean equals(final Object obj) {
    if (this == obj)
    	return true;
    if (obj == null)
    	return false;
    if (!(obj instanceof IPatternMatch))
    	return false;
    IPatternMatch otherSig  = (IPatternMatch) obj;
    if (!pattern().equals(otherSig.pattern()))
    	return false;
    if (!InvalidDotNetBusinessServiceDependencyMatch.class.equals(obj.getClass()))
    	return Arrays.deepEquals(toArray(), otherSig.toArray());
    				InvalidDotNetBusinessServiceDependencyMatch other = (InvalidDotNetBusinessServiceDependencyMatch) obj;
    				if (fDotNetService == null) {if (other.fDotNetService != null) return false;}
    				else if (!fDotNetService.equals(other.fDotNetService)) return false;
    				if (fOtherService == null) {if (other.fOtherService != null) return false;}
    				else if (!fOtherService.equals(other.fOtherService)) return false;
    				return true;
    
  }
  
  @Override
  public Pattern pattern() {
    return InvalidDotNetBusinessServiceDependencyMatcher.FACTORY.getPattern();
  }
}
